﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace SLASCIICore
{
    public partial class GridCell : UserControl
    {
        private List<Rectangle> rectangles = new List<Rectangle>();
        public Rectangle this[int index]
        {
            get
            {
                if (index >= 0 && index < rectangles.Count)
                {
                    return rectangles[index];
                }
                else
                {
                    return null;
                }
            }
        }
        private int column;
        public int Column
        {
            get
            {
                return column;
            }
            set
            {
                column = value;
            }
        }
        private int row;
        public int Row
        {
            get
            {
                return row;
            }
            set
            {
                row = value;
            }
        }
        private int layers = 0;
        public int Layers
        {
            get
            {
                return layers;
            }
            set
            {
                if (layers != value)
                {
                    layers = value;
                    while (layers < rectangles.Count)
                    {
                        LayoutRoot.Children.Remove(rectangles[rectangles.Count - 1]);
                        rectangles.Remove(rectangles[rectangles.Count - 1]);
                    }
                    while (layers > rectangles.Count)
                    {
                        Rectangle rectangle = new Rectangle();
                        LayoutRoot.Children.Add(rectangle);
                        rectangles.Add(rectangle);
                    }
                }
            }
        }
        public GridCell()
        {
            InitializeComponent();
        }

    }
}
